package com.example.nonggo.view.act;

import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

import com.allen.library.RxHttpUtils;
import com.allen.library.interceptor.Transformer;
import com.bumptech.glide.Glide;
import com.example.nonggo.Constants;
import com.example.nonggo.R;
import com.example.nonggo.api.BaseApi;
import com.example.nonggo.api.MDataObserver;
import com.example.nonggo.bean.ShowIconTab;
import com.tencent.mmkv.MMKV;

/**
 * 该类由 语音对话改为展示小程序二维码
 */
public class CallInCallActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_call_in_call);
        // 隐藏状态栏
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        );
        getData();
    }

    void getData() {
        // 获取数据
        String token = MMKV.defaultMMKV().getString(Constants.ACCESS_TOKEN, "0");
        BaseApi api = RxHttpUtils.createApi(BaseApi.class);
        api.tab4ImageDetail(token) .compose(Transformer.switchSchedulers(null))
                .subscribe(new MDataObserver<ShowIconTab>() {
                    @Override
                    protected void onSuccess(ShowIconTab data) {
                        ImageView view = findViewById(R.id.qrcode);
                        findViewById(R.id.pb_loading).setVisibility(View.GONE);
                        view.setVisibility(View.VISIBLE);
                       // 加载图片
//                        view.setImageURI(Uri.parse(data.getIcon()));
                        Glide.with(view).load(data.getIcon()).into(view);
                    }
                });
    }

}